package com.adou.controller;

import com.adou.domain.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("users")
public class BookController {
    @Value("${lesson}")
    private String lesson;

    @Value("${server.port}")
    private String port;

    @Value("${enterprise.subject[0]}")
    private String subject0;

    @Autowired
    private Environment environment;

    @Autowired
    private Enterprise enterprise;

    @GetMapping("/{id}")
    public String getById(@PathVariable Integer id){
        System.out.println("id:-----------" + id);
        System.out.println("lesson:-----------" + lesson);
        System.out.println("port:-----------" + port);
        System.out.println("subject0:-----------" + subject0);
        System.out.println("environment.name:-----------" + environment.getProperty("enterprise.subject[0]"));
        System.out.println("enterprise.name:-----------" + enterprise.getName());
        return "hello, springboot";
    }

}
